package com.ruoyi.system.service.impl;

import java.util.List;

import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.system.domain.SysControl;
import com.ruoyi.system.domain.vo.ControlFieldVO;
import com.ruoyi.system.domain.vo.SysControlVO;
import com.ruoyi.system.mapper.SysControlMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.ControlFieldMapper;
import com.ruoyi.system.domain.ControlField;
import com.ruoyi.system.service.IControlFieldService;

/**
 * 控件字段Service业务层处理
 * 
 * @author ruoyi
 * @date 2024-02-26
 */
@Service
public class ControlFieldServiceImpl implements IControlFieldService 
{
    @Autowired
    private ControlFieldMapper controlFieldMapper;

    @Autowired
    private SysControlMapper controlMapper;

    /**
     * 查询控件字段
     * 
     * @param fieldId 控件字段主键
     * @return 控件字段
     */
    @Override
    public ControlField selectControlFieldByFieldId(Long fieldId)
    {
        return controlFieldMapper.selectControlFieldByFieldId(fieldId);
    }

    /**
     * 查询控件字段列表
     * 
     * @param controlField 控件字段
     * @return 控件字段
     */
    @Override
    public List<ControlField> selectControlFieldList(ControlField controlField)
    {
        return controlFieldMapper.selectControlFieldList(controlField);
    }

    @Override
    public List<ControlFieldVO> selectControlFieldVOList(ControlField controlField) {
        List<ControlFieldVO> controlFieldVOS = controlFieldMapper.selectControlFieldVOList(controlField);
        for(ControlFieldVO vo : controlFieldVOS){
            SysControlVO sysControlVO = controlMapper.selectSysControlByControlId(vo.getControlId());
            vo.setControlVO(sysControlVO);
        }
        return controlFieldVOS;
    }

    /**
     * 新增控件字段
     * 
     * @param controlField 控件字段
     * @return 结果
     */
    @Override
    public int insertControlField(ControlField controlField)
    {
        return controlFieldMapper.insertControlField(controlField);
    }

    /**
     * 修改控件字段
     * 
     * @param controlField 控件字段
     * @return 结果
     */
    @Override
    public int updateControlField(ControlField controlField)
    {
        return controlFieldMapper.updateControlField(controlField);
    }

    /**
     * 批量删除控件字段
     * 
     * @param fieldIds 需要删除的控件字段主键
     * @return 结果
     */
    @Override
    public int deleteControlFieldByFieldIds(Long[] fieldIds)
    {
        return controlFieldMapper.deleteControlFieldByFieldIds(fieldIds);
    }

    /**
     * 删除控件字段信息
     * 
     * @param fieldId 控件字段主键
     * @return 结果
     */
    @Override
    public int deleteControlFieldByFieldId(Long fieldId)
    {
        return controlFieldMapper.deleteControlFieldByFieldId(fieldId);
    }
}
